#include "stdafx.h"
#include "Employee.h"
#include "AirportManager.h"
#include "AirlineRep.h"
#include "AircraftType.h"
#include "GroundTrafficController.h"
#include <iostream>
#include <stdio.h>

const int DEALLTIME = 15;

using namespace std;



/*------------------------------------------------------------
/ constructor
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: creates the manager
/ Paramneters: 
/ Return: 
------------------------------------------------------------*/
AirportManager::AirportManager() : Employee("APM1","password"){
	airlineRepList = new list<AirlineRep> ();
	gateStandList = new list<GateStand> ();
	longTermStandList = new list<LongTermStand> ();
	typeList = new list<AircraftType> ();
	flightRequestList = new list<Flight> ();

	//PASS IN THE STAND LISTS SO THEY POINT TO THE SAME OBJECT
	gTCAccount = new GroundTrafficController ();
}

/*------------------------------------------------------------
/ destructor
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes the manager
/ Paramneters: 
/ Return: 
------------------------------------------------------------*/
AirportManager::~AirportManager(){
}

/*------------------------------------------------------------
/ login
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::login(string empID, string pWord){
	
	std::list<AirlineRep>::iterator it;
	int flag = 0;

	if (empID.compare (gTCAccount->getEmployeeID()) == 0){
		if (pWord.compare(gTCAccount->getEmployeePassword()) == 0){
			return 1; //password correct for manager
		}else{
			return 0; //password incorrect for manager
		}
	}else if (empID.compare(getEmployeeID()) == 0){

		if (pWord.compare(getEmployeePassword()) == 0){
			return 1; //password correct for manager
		}else{
			return 0; //password incorrect for manager
		}
	}else{
			if (!airlineRepList->empty()){
				it = airlineRepList->begin();

				//find the position for the flight object in the list
				for (it = airlineRepList->begin() ;!flag && it != airlineRepList->end(); ++it){	
					if (empID.compare(it->getEmployeeID()) == 0){
						flag = 1;
					}
				}

				if (!flag){
					return 0; //no employee with that ID
				}else{
					if (it->getEmployeePassword().compare(pWord) == 0){
						return 1; //correct password
					}else{
						return 0; //password of ARP incorrect
					}
				}
			}else{
				return 0; //no airline reps present
			}
	}
}

/*------------------------------------------------------------
/ changePassword
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::changePassword(string old_pw, string new_pw){
	//check the old password
	if (this->getEmployeePassword ().compare(old_pw)  == 0){
		this->setEmployeePassword(new_pw);
		return 1; //success
	}
	return 0; //failed
}

/*------------------------------------------------------------
/ changeARPPassword
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::changeARPPassword(string id, string old_pw, string new_pw){
	std::list<AirlineRep>::iterator it;
	int flag = 0;

	if (airlineRepList->empty()){
		return 0; //no accounts available
	}else{
			//find the position for the flight object in the list
		for (it = airlineRepList->begin() ;!flag && it != airlineRepList->end(); ++it){	
			if (it->getEmployeeID().compare(id)  == 0){
				return it->changePassword(old_pw, new_pw); //found airline rep
			}
		}

		return 0; //not found
	}
}

/*------------------------------------------------------------
/ registerEmployee
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::registerEmployee(string empID, string pWord){
	
	std::list<AirlineRep>::iterator it;
	int flag = 0;
	
	if (AirportManager::startsWith(empID, "GTC")){
		if (gTCAccount->getEmployeeID().compare("")  == 0){
			if (pWord.size() > 0){
				gTCAccount = new GroundTrafficController (empID, pWord);
				return 1; //account created
			}else{
				return 0; //Password must be > 0 characters
			}
		}else{
			return 0; //GTC account already exists
		}
	}else if (AirportManager::startsWith(empID, "ARP")){

		//create the employee
		AirlineRep *newRep = new AirlineRep (empID, pWord);

		if (airlineRepList->empty()){
			airlineRepList->push_front(*newRep);
			return 1; //account created
		}else{
			//find the position for the flight object in the list
			for (it = airlineRepList->begin() ;!flag && it != airlineRepList->end(); ++it){	
				if (it->getEmployeeID().compare(empID)  == 0){
					flag = 1;
				}
			}

			if (flag){
				return 0; //airline rep exists with same ID
			}else{
				airlineRepList->push_back(*newRep);
				return 1; //account created
			}
		}
	}else{
		return 0; //incorrect ID format
	}
}

/*------------------------------------------------------------
/ modifyEmployee
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::modifyEmployee(string empID, string pWord, string newID, string newPWord){
	std::list<AirlineRep>::iterator it;
	int flag = 0 ;
	
	if (empID.compare(gTCAccount->getEmployeeID()) == 0 && pWord.compare(gTCAccount->getEmployeePassword()) == 0){
		if (AirportManager::startsWith(newID, "GTC") && newPWord.size() > 0){
			gTCAccount->setEmployeeID(newID);
			gTCAccount->setEmployeePassword(newPWord);
			return 1; //account modified
		}else{
			return 0; //wrong format for new ID
		}
	}else if (empID.compare(getEmployeeID()) == 0 && pWord.compare(getEmployeePassword()) == 0){
		if (AirportManager::startsWith(newID, "APM") && newPWord.size() > 0){
			setEmployeeID(empID);
			setEmployeePassword(newPWord);
			return 1; //success
		}else{
			return 0; //wrong format for new ID
		}
	}else{

		if (airlineRepList->empty()){
			return 0; //no accounts present
		}else{
			
			//find the position for the airline rep object in the list
			for (it = airlineRepList->begin() ; it != airlineRepList->end(); ++it){	
				if (it->getEmployeeID().compare(newID)  == 0){
					return 0; //newId already in use

					//COULD CHECK IF OLD ID AND NEW ID ARE SAME, THEN JUST CALL CHANGE PASSWORD

				}
			}

			//find the position for the airline rep object in the list
			for (it = airlineRepList->begin() ;!flag && it != airlineRepList->end(); ++it){	
				if (it->getEmployeeID().compare(empID)  == 0){
					flag = 1;
				}
			}

			it --; // reference back to the object we want

			//Airline rep has been found or not
			if (flag){
				if (AirportManager::startsWith(newID, "ARP") && newPWord.size() > 0){

					it->setEmployeeID(newID);
					it->setEmployeePassword(newPWord);

					return 1; //account modified
				}else{
					return 0; //new ID in wrong format
				}
			}else{
				return 0; //no employee with specified ID
			}
		}
	}
}

/*------------------------------------------------------------
/ deleteEmployee
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::deleteEmployee(string empID, string pWord){

	int flag = 0;

	if (gTCAccount->getEmployeeID().compare(empID)  == 0 && gTCAccount->getEmployeePassword().compare(pWord)  == 0){			
		
		list<GateStand> *t1 = gTCAccount->getGateStandList();
		list<LongTermStand> *t2 = gTCAccount->getLongTermStandList();

		//if the lists for the GTC are empty, it can be deleted
		if (t1->empty() && t2->empty()){
			gTCAccount = new GroundTrafficController ();
			return 1; //account deleted
		}else{
			return 0; //GTC account not cleared
		}
	}else{

		std::list<AirlineRep>::iterator it;

		//create the employee
		AirlineRep *newRep = new AirlineRep (empID, pWord);

		if (airlineRepList->empty()){
			return 0; //no accounts present
		}else{


			//find the position for the airline rep object in the list
			for (it = airlineRepList->begin() ;!flag && it != airlineRepList->end(); ++it){	
				if (it->getEmployeeID().compare(empID) == 0 && it->getEmployeePassword().compare(pWord)  == 0){
					flag = 1;
				}
			}

			it --; // reference back to the object we want

			if (flag){
				if (it->emptyList()){
					airlineRepList->erase(it);
					return 1; //account deleted
				}else{
					return 0; //the object to be deleted wasnt empty
				}
			}else{
				return 0; //airline rep doesnt exist
			}
		}
	}
}

/*------------------------------------------------------------
/ registerStand
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::registerGateStand(string sID){
	
	std::list<GateStand>::iterator it;
	int flag = 0;

	if(AirportManager::startsWith(sID, "GTS")){
		if (gateStandList->empty()){
			GateStand *temp = new GateStand (sID);
			gateStandList->push_front(*temp);
			return 1;//success
		}else{
			for (it = gateStandList->begin(); !flag && it != gateStandList->end(); ++it){
				if (it->getStandID().compare(sID)  == 0){
					flag = 1;
				}
			}

			it --; // reference back to the object we want

			if (flag){
				return 0; //stand exists
			}else{
				GateStand *temp = new GateStand (sID);
				gateStandList->push_back(*temp);
				return 1; //success
			}
		}
	}else{
		return 0; //wrong format
	}
}

/*------------------------------------------------------------
/ registerStand
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/

int AirportManager::registerLongTermStand(string sID){
	
	std::list<LongTermStand>::iterator it;
	int flag = 0;

	if(AirportManager::startsWith(sID, "LTS")){
		if (longTermStandList->empty()){
			LongTermStand *temp = new LongTermStand (sID);
			longTermStandList->push_front(*temp);
			return 1;//success
		}else{
			for (it = longTermStandList->begin(); !flag && it != longTermStandList->end(); ++it){
				if (it->getStandID().compare(sID)  == 0){
					flag = 1;
				}
			}

			it --; // reference back to the object we want

			if (flag){
				return 0; //stand exists
			}else{
				LongTermStand *temp = new LongTermStand (sID);
				longTermStandList->push_back(*temp);
				return 1; //success
			}
		}
	}else{
		return 0; //wrong format
	}

	
	return 0;
}


/*------------------------------------------------------------
/ modifyStand
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::modifyGateStand(string stID, AircraftType *type, int m){
    
	//-------------------------------------
	// if m = 0, the modify is meant to delete a Type
	// if m = 1, the modify is meant to add a new type
	//------------------------------------

	list<GateStand>::iterator ltsIt;
	list<AircraftType>::iterator it;

	if (gateStandList->empty()){
		return 0; //cannot modify, list empty
	}else{

		if (gateStandList->empty()){
			return 0; //cant modify because no stands exist
		}else{
			if (m == 0){
			//go through list of GateStands looking for id 
				for (ltsIt = gateStandList->begin(); ltsIt != gateStandList->end(); ++ltsIt){
					if (ltsIt->getStandID().compare(stID) == 0){    //
						for (it = ltsIt->typeList->begin(); it != ltsIt->typeList->end(); ++it){
							if (it->getModel() == type->getModel()){
								ltsIt->typeList->erase(it); //removes the aircraft type specified
								return 1;        //GateStand id updated
							}
						}
					}
				}	
				return 0; //aircraft type does not exist
			}else{
				//go through list of GateStands looking for id 
				for (ltsIt = gateStandList->begin(); ltsIt != gateStandList->end(); ++ltsIt){
					if (ltsIt->getStandID().compare(stID) == 0){    //
						for (it = ltsIt->typeList->begin(); it != ltsIt->typeList->end(); ++it){
							if (it->getModel() == type->getModel()){
								return 0;        //Aircraft Type already present
							}
						}
						ltsIt->typeList->push_back(*type); // doesnt exist, so add it to the list
						return 1;        //Aircraft Type inserted
					}
				}
				return 0;        //Gatestand not present
			}
		}
	}
}

/*------------------------------------------------------------
/ modifyStand
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/

int AirportManager::modifyLongTermStand(string stID, AircraftType *type, int m){

	//-------------------------------------
	// if m = 0, the modify is meant to delete a Type
	// if m = 0, the modify is meant to add a new type
	//------------------------------------

	list<LongTermStand>::iterator ltsIt;
	list<AircraftType>::iterator it;

	if (longTermStandList->empty()){
		return 0; //cannot modify, list empty
	}else{
		if (m == 0){
		//go through list of GateStands looking for id 
			for (ltsIt = longTermStandList->begin(); ltsIt != longTermStandList->end(); ++ltsIt){
				if (ltsIt->getStandID().compare(stID) == 0){    //
					for (it = ltsIt->typeList->begin(); it != ltsIt->typeList->end(); ++it){
						if (it->getModel() == type->getModel()){
							ltsIt->typeList->erase(it); //removes the aircraft type specified
							return 1;        //GateStand updated
						}
					}
				}
			}		
			return 0; //aircraft type does not exist
		}else{
			//go through list of GateStands looking for id 
			for (ltsIt = longTermStandList->begin(); ltsIt != longTermStandList->end(); ++ltsIt){
				if (ltsIt->getStandID().compare(stID) == 0){    //
					for (it = ltsIt->typeList->begin(); it != ltsIt->typeList->end(); ++it){
						if (it->getModel() == type->getModel()){
							return 0;        //Aircraft Type already present
						}
					}
					ltsIt->typeList->push_back(*type); // doesnt exist, so add it to the list
					return 1; //aircraft type added
				}
			}
			return 0; //aircraft type does not exist
		}
	}
}

/*------------------------------------------------------------
/ deleteStand
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::deleteStand(string _ID){

	//create an iterator to walk through the lists of stands and delete the chosen stand
	std::list<LongTermStand>::iterator it;
	std::list<GateStand>::iterator it2;
	int flag = 0;

	if (AirportManager::startsWith(_ID, "LTS")){

		//check if the list is empty
		if (longTermStandList->empty()){
			return 0; //stand doesnt exist
		}

		//first walk through the list of long term stands from start to finish
		for(it = longTermStandList->begin() ; !flag && it != longTermStandList->end(); ++it){
			//if an ID matching _st is found, remove that item from the longTermStandList
			if(it->getStandID().compare(_ID) == 0){
				flag = 1;
			}
		}

		it --; // reference back to the object we want

		//remove the stand if found
		if (flag){

			if (!(it->standStatus == 0)){
				return 0; //stand must be empty before it can be deleted
			}

			longTermStandList->erase(it);
			return 1; //successfully removed

		}else{
			return 0; //stand does not exist
		}

	}else if (AirportManager::startsWith(_ID, "GTS")){

		//check if the list is empty
		if (gateStandList->empty()){
			return 0; //stand doesnt exist
		}

		//first walk through the list of gate  stands from start to finish
		for(it2 = gateStandList->begin(); !flag && it2 != gateStandList->end(); ++it2){
			//if an ID matching _st is found, remove that item from the longTermStandList
			if(it2->getStandID().compare(_ID)  == 0){
				flag = 1;
			}
		}

		it2--;  // reference back to the object we want

		//remove the stand if found
		if (flag){

			if (!(it2->standStatus == 0)){
				return 0; //stand must be empty before it can be deleted
			}

			if (it2->accomodationList->empty()){
				gateStandList->erase(it2);
				return 1; //successfully removed
			}else{
				return 0; //stand must have no associated flights in order to delete
			}
		}else{
			return 0; //stand does not exist
		}

	}else{
		return 0;
	}
}

/*------------------------------------------------------------
/ importAirportData
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::importAirportData(string data){
	return 0;
}

/*------------------------------------------------------------
/ outputAirportData
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::exportAirportData(string data){
	return 0;
}

/*------------------------------------------------------------
/ registerAircraftType
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes in an aircraft type
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::registerAircraftType(AircraftType *type){
	string ID = type->getModel();
	std::list<AircraftType>::iterator it;
	int flag = 0;

	if (typeList->empty()){
		//if the list is empty, we can add without checking
		typeList->push_front(*type);
		return 1; //success
	}else{
		for (it = typeList->begin();!flag && it != typeList->end(); ++it){
			if (it->getModel().compare(ID) == 0){
				flag = 1;
			}
		}

		if (flag){
			return 0; //type alrady exists
		}else{
			typeList->push_back(*type);
			return 1; //success
		}
	}
}

/*------------------------------------------------------------
/ deleteAircraftType
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes a valid ID in string form 
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/

int AirportManager::deleteAircraftType(string ID){
	std::list<AircraftType>::iterator it;
	std::list<AirlineRep>::iterator it1;
	std::list<Aircraft>::iterator it2;
	std::list<GateStand>::iterator it3;
	std::list<LongTermStand>::iterator it4;
	std::list<AircraftType>::iterator it5;
	int flag = 0;
	int isUsed = 0;

	if (typeList->empty()){
		//if the list is empty, cannot delete
		return 0;
	}else{
		for (it = typeList->begin();!flag && it != typeList->end(); ++it){
			if (it->getModel().compare(ID) == 0){
				flag = 1;
			}
		}

		it --; // reference back to the object we want

		if (flag){

			//Check to see if the aircraft type is being used by an aircraft
			for (it1 = airlineRepList->begin(); !isUsed && it1 != airlineRepList->end(); ++it1){
				for (it2 = it1->aircraftList->begin(); !isUsed && it2 != it1->aircraftList->end(); ++it2){
					if (it2->getAircraftType()->getModel().compare(ID) == 0){
						isUsed = 1;
					}
				}
			}
			
			//Check to see if a gate stand still accomodates this aircraft type
			for (it3 = gateStandList->begin(); !isUsed && it3 != gateStandList->end(); ++it3){
				for (it5 = it3->typeList->begin(); !isUsed && it5 != it3->typeList->end(); ++it5){
					if (it5->getModel().compare(ID) == 0){
						isUsed = 1;
					}
				}
			}

			//Check to see if a long term stand still accomodates this aircraft type
			for (it4 = longTermStandList->begin(); !isUsed && it4 != longTermStandList->end(); ++it4){
				for (it5 = it4->typeList->begin(); !isUsed && it5 != it4->typeList->end(); ++it5){
					if (it5->getModel().compare(ID) == 0){
						isUsed = 1;
					}
				}
			}

			if (isUsed == 0){
				typeList->erase(it);
				return 1; //success
			}else{
				return 0; //type is part of planes
			}
		}else{
			return 0; //type nmot found
		}
	}
}

/*------------------------------------------------------------
/ modifyAircraftType
/ By: Trevor Plint
/ Date: March 17 2011
/ Description: deletes a stand by ID  
/ Paramneters: takes in an aircraft type
/ Return: 0 if stand cannot be deleted for ligistical reasons
          1 if stand deleted successfully
         0 if stand not found
------------------------------------------------------------*/
int AirportManager::modifyAircraftType(string ID, AircraftType *type){
	std::list<AircraftType>::iterator it;
	std::list<AirlineRep>::iterator it1;
	std::list<Aircraft>::iterator it2;
	std::list<GateStand>::iterator it3;
	std::list<LongTermStand>::iterator it4;
	std::list<AircraftType>::iterator it5;
	int flag = 0;
	int isUsed = 0;

	if (typeList->empty()){
		//if the list is empty, cannot delete
		return 0;
	}else{
		for (it = typeList->begin();!flag && it != typeList->end(); ++it){
			if (it->getModel().compare(ID) == 0){
				flag = 1;
			}
		}

		it --; // reference back to the object we want

		if (flag){

			//Check to see if the aircraft type is being used by an aircraft
			if (!airlineRepList->empty()){
				for (it1 = airlineRepList->begin(); !isUsed && it1 != airlineRepList->end(); ++it1){
					for (it2 = it1->aircraftList->begin(); !isUsed && it2 != it1->aircraftList->end(); ++it2){
						if (it2->getAircraftType()->getModel().compare(ID) == 0){
							isUsed = 1;
						}
					}
				}
			}
			
			//Check to see if a gate stand still accomodates this aircraft type
			if (!gateStandList->empty()){
				for (it3 = gateStandList->begin(); !isUsed && it3 != gateStandList->end(); ++it3){
					for (it5 = it3->typeList->begin(); !isUsed && it5 != it3->typeList->end(); ++it5){
						if (it5->getModel().compare(ID) == 0){
							isUsed = 1;
						}
					}
				}
			}

			//Check to see if a long term stand still accomodates this aircraft type
			if (!longTermStandList->empty()){
				for (it4 = longTermStandList->begin(); !isUsed && it4 != longTermStandList->end(); ++it4){
					for (it5 = it4->typeList->begin(); !isUsed && it5 != it4->typeList->end(); ++it5){
						if (it5->getModel().compare(ID) == 0){
							isUsed = 1;
						}
					}
				}
			}

			if (isUsed == 0){
				it->setBoardingTime(type->getBoardingTime());
				it->setCapacity(type->getCapacity());
				it->setManu(type->getManu());
				it->setServiceTime(type->getServiceTime());
				return 1; //success
			}else{
				return 0; //type is part of planes
			}
		}else{
			return 0; //type nmot found
		}
	}
}

/*------------------------------------------------------------
/ startsWith
/ By: Mark Freedman
/ Date: March 17 2011
/ Description: determines if a string starts with another string
/ Paramneters: The string to search, the beginning string
/ Return: 0 if it does not start with it
          1 if it does start with it
------------------------------------------------------------*/

int AirportManager::startsWith (std::string w, std::string b){

	unsigned int i;

	//check that w is larger than the begin word
	if (b.size() > w.size()){
		return 0; //cannot begin with this
	}

	//check that b and w are both larger than 0
	if (!(b.size() > 0 && w.size() > 0)){
		return 0;
	}

	for (i = 0; i < b.size(); i++){
		if (!(w.at(i) == b.at(i))){
			return 0;
		}
	}

	//w starts with b
	return 1;
}
